package com.emperor.transaction.logic;

import java.util.ArrayList;
import java.util.List;

import com.emperor.core.logic.BizModelBase;
import com.emperor.course.logic.Course;
import com.emperor.product.logic.Product;
import com.emperor.receipt.logic.Receipt;
import com.emperor.treatment.logic.Treatment;

public class TransactionModel extends BizModelBase implements Transaction {

	private Long id;	
	private Double price;
	private Double specialprice;
	private Double discount;
	private Receipt receipt;
	private String status;
	private Double quantity;
	private Double weight;
	private String weightuom;
	private Double subtotal;
	private Boolean custdiscount;
	private Double discountamt;
	private Double totalcost;
	private Integer type;
	
	private Product product;
	private Course course;
	private Treatment treatment;
	
	public Course getCourse() {
		return course;
	}

	public void setCourse(Object course) {
		if (course != null) {
			if (course instanceof Course) {
				this.course = (Course) course;
			}
		}
	}

	public Treatment getTreatment() {
		return treatment;
	}

	public void setTreatment(Object treatment) {
		if (treatment != null) {
			if (treatment instanceof Treatment) {
				this.treatment = (Treatment) treatment;
			}
		}
	}

	public Long getId() {
		return id;
	}

	public void setId(Object id) {
		if (id != null) {
			if (id instanceof Long) {
				this.id = (Long) id;
			} else {
				try {
					this.id = new Long(id.toString());
				} catch (Exception e) {
				}
			}
		}
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Object product) {
		if (product != null) {
			if (product instanceof Product) {
				this.product = (Product) product;
			}
		}
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Object price) {
		if (price != null) {
			if (price instanceof Double) {
				this.price = (Double) price;
			} else {
				try {
					this.price = new Double(price.toString());
				} catch (Exception e) {
				}
			}
		}
	}

	public Double getDiscount() {
		return discount;
	}

	public void setDiscount(Object discount) {
		if (discount != null) {
			if (discount instanceof Double) {
				this.discount = (Double) discount;
			} else {
				try {
					this.discount = new Double(discount.toString());
				} catch (Exception e) {
				}
			}
		}
	}

	public Receipt getReceipt() {
		return receipt;
	}

	public void setReceipt(Object receipt) {
		if (receipt != null) {
			if (receipt instanceof Receipt) {
				this.receipt = (Receipt) receipt;
			}
		}
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(Object status) {
		if (status != null) {
			if (status instanceof String) {
				this.status = (String) status;
			} else {
				try {
					this.status = status.toString();
				} catch (Exception e) {
				}
			}
		}
	}

	@Override
	public List<String> getFieldNames() {
		List<String> fieldNames = new ArrayList<String>();
		
		fieldNames.add(FLD_ID);
		fieldNames.add(FLD_PRODUCT);
		fieldNames.add(FLD_PRICE);
		fieldNames.add(FLD_SPECIALPRICE);
		fieldNames.add(FLD_DISCOUNT);
		fieldNames.add(FLD_RECEIPT);
		fieldNames.add(FLD_STATUS);
		fieldNames.add(FLD_QUANTITY);
		fieldNames.add(FLD_WEIGHT);
		fieldNames.add(FLD_WEIGHTUOM);
		fieldNames.add(FLD_SUBTOTAL);
		fieldNames.add(FLD_DISCOUNTAMT);
		fieldNames.add(FLD_TOTALCOST);
		fieldNames.add(FLD_TYPE);
		
		fieldNames.add(FLD_CRTBY);
		fieldNames.add(FLD_CRTDATE);
		fieldNames.add(FLD_UPDBY);
		fieldNames.add(FLD_UPDDATE);
		
		return fieldNames;
	}

	public Double getQuantity() {
		return quantity;
	}

	public void setQuantity(Object quantity) {
		if (quantity != null) {
			if (quantity instanceof Double) {
				this.quantity = (Double) quantity;
			} else {
				try {
					this.quantity = new Double(quantity.toString());
				} catch (Exception e) {
				}
			}
		}
	}

	public Double getSubtotal() {
		return subtotal;
	}

	public void setSubtotal(Object subtotal) {
		if (subtotal != null) {
			if (subtotal instanceof Double) {
				this.subtotal = (Double) subtotal;
			} else {
				try {
					this.subtotal = new Double(subtotal.toString());
				} catch (Exception e) {
				}
			}
		}
	}

	public Boolean getCustdiscount() {
		return custdiscount;
	}

	public void setCustdiscount(Object custdiscount) {
		if (custdiscount != null) {
			if (custdiscount instanceof Boolean) {
				this.custdiscount = (Boolean) custdiscount;
			} else {
				try {
					this.custdiscount = new Boolean(custdiscount.toString());
				} catch (Exception e) {
				}
			}
		}
	}

	public Double getWeight() {
		return weight;
	}

	public void setWeight(Object weight) {
		if (weight != null) {
			if (weight instanceof Double) {
				this.weight = (Double) weight;
			} else {
				try {
					this.weight = new Double(weight.toString());
				} catch (Exception e) {
				}
			}
		}
	}

	public String getWeightuom() {
		return weightuom;
	}

	public void setWeightuom(Object weightuom) {
		if (weightuom != null) {
			if (weightuom instanceof String) {
				this.weightuom = (String) weightuom;
			} else {
				try {
					this.weightuom = weightuom.toString();
				} catch (Exception e) {
				}
			}
		}
	}

	public Double getSpecialprice() {
		return specialprice;
	}

	public void setSpecialprice(Object specialprice) {
		if (specialprice != null) {
			if (specialprice instanceof Double) {
				this.specialprice = (Double) specialprice;
			} else {
				try {
					this.specialprice = new Double(specialprice.toString());
				} catch (Exception e) {
				}
			}
		} else {
			this.specialprice = null;
		}
	}

	public Double getDiscountamt() {
		return discountamt;
	}

	public void setDiscountamt(Object discountamt) {
		if (discountamt != null) {
			if (discountamt instanceof Double) {
				this.discountamt = (Double) discountamt;
			} else {
				try {
					this.discountamt = new Double(discountamt.toString());
				} catch (Exception e) {
				}
			}
		}
	}

	public Double getTotalcost() {
		return totalcost;
	}

	public void setTotalcost(Object totalcost) {
		if (totalcost != null) {
			if (totalcost instanceof Double) {
				this.totalcost = (Double) totalcost;
			} else {
				try {
					this.totalcost = new Double(totalcost.toString());
				} catch (Exception e) {
				}
			}
		}
	}

	public Integer getType() {
		return type;
	}

	public void setType(Object type) {
		if (type != null) {
			if (type instanceof Integer) {
				this.type = (Integer) type;
			} else {
				try {
					this.type = new Integer(type.toString());
				} catch (Exception e) {
				}
			}
		}
	}

	
}
